package com.jinzhi.common.filter;

import com.jinzhi.common.configconsts.wxconsts.LinkConfiggure;
import com.jinzhi.common.vo.WxPayVo;
import com.jinzhi.common.utils.ApiResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Slf4j
@Component
public class WxOrderBusinessFilter implements Command{

    private static BigDecimal bigDecimal ;

    static {
        bigDecimal = new BigDecimal(100);
    }

    @Override
    public boolean execute(Context context) {
        log.info("链路:微信支付执行到:下单业务处理");

        //获取支付对象
        WxPayVo wxPayVo = (WxPayVo) context.get(LinkConfiggure.WX_PAY_VO);

        //获取返回对象
        ApiResult apiResult = (ApiResult) context.get(LinkConfiggure.API_RESULT);

        //获取订单id
        Integer order_id = (Integer) context.get("order_id");

        try {
            //todo 对订单相关信息做相关处理，比如添加支付记录、修改票数等

        }catch (Exception e){
            apiResult.setCode(LinkConfiggure.WX_ERROR_CODE);
            apiResult.setMsg("订单下单业务处理失败");
            return true;
        }
        return false;
    }
}
